package com.lenovo.leos.letools;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import android.os.Environment;
import android.test.AndroidTestCase;
import android.util.Log;

import com.lenovo.leos.letools.domain.Folder;
import com.lenovo.leos.letools.domain.LoadFile;
import com.lenovo.leos.letools.lenovodata.DownloadDirServer;

/**
 * junit test
 * 
 * @author cys
 */
public class TestDownloadDirServer extends AndroidTestCase {

	private DownloadDirServer dds;
	
	public TestDownloadDirServer(){
		dds = new DownloadDirServer(null);
	}

	public void testRecursiveList()throws Exception{
		List<Folder> root = new ArrayList<Folder>();
//		root.add(new Folder("1301279145610203981","root"));
		root.add(new Folder("1301670885239201246","parentDir1"));
		dds.recursiveList(this.getContext(),root,0);
	}
	
	public void testRecursiveMapingWholePathAndFileInf()throws Exception{
		List<Folder> root = new ArrayList<Folder>();
		root.add(new Folder("1301279145610203981","root"));
		File sdcardRoot = Environment.getExternalStorageDirectory();
		Map<String,List<LoadFile>> map = new HashMap<String, List<LoadFile>>();
		
		dds.recursiveMapingWholePathAndFileInf(this.getContext(),root,sdcardRoot,map);
		
		Set<Map.Entry<String,List<LoadFile>>> entitys = map.entrySet();
		for(Map.Entry<String,List<LoadFile>> entry:entitys){
			String wholePath = entry.getKey();
			List<LoadFile> loadFiles = entry.getValue();
			for(LoadFile lf:loadFiles){
				Log.i("mapping","============="+wholePath+" : "+lf);
			}
		}
	}
	
	public void testrecursiveDownloadFile()throws Exception{
		List<Folder> root = new ArrayList<Folder>();
		root.add(new Folder("1301279145610203981","root"));
		dds.recursiveDownloadFile(this.getContext(),root,0);
	}
}
